﻿using System;

namespace PropertyExpression.DynamicQueryStaticChecking.Test
{
    public partial class PartLinkQueryProvider : IQueryProvider<PartLinkInfo>
    {
        public readonly IParamManager<PartLinkParams> PartLinkParams;
        private readonly IInnerPartLinkSwitcher innerPartLinkSwitcher;

        public PartLinkQueryProvider(
            IParamManager<PartLinkParams> partLinkParams, IInnerPartLinkSwitcher innerPartLinkSwitcher)
        {
            PartLinkParams = partLinkParams;
            this.innerPartLinkSwitcher = innerPartLinkSwitcher;
        }
    }

    public partial class PartLinkInfo
    {
    }

    public partial class PartLinkParams
    {
    }

    public interface IInnerPartLinkSwitcher
    {
        void AddSubQuery(Action<bool> action);
    }

    public class WithoutInnerPartLinkSwitcher : IInnerPartLinkSwitcher
    {
        public void AddSubQuery(Action<bool> action)
        {
            //no-op
        }
    }

    public class WithInnerPartLinkSwitcher : IInnerPartLinkSwitcher
    {
        public readonly IParamManager<InnerPartLinkParams> InnerPartLinkParams;
        private readonly bool latestPublicationOnly;

        public WithInnerPartLinkSwitcher(
            IParamManager<InnerPartLinkParams> innerPartLinkParams, bool latestPublicationOnly)
        {
            InnerPartLinkParams = innerPartLinkParams;
            this.latestPublicationOnly = latestPublicationOnly;
        }

        public void AddSubQuery(Action<bool> action)
        {
            action(latestPublicationOnly);
        }
    }

    public partial class InnerPartLinkParams
    {
    }




    public partial class PartLinkParams
    {
        public readonly Guid GenericServicePartsPageID;
        public readonly Guid ModelPublicationID;
        public readonly Guid ServicePartsPageID;

        public PartLinkParams(Guid genericServicePartsPageID, Guid modelPublicationID, Guid servicePartsPageID)
        {
            GenericServicePartsPageID = genericServicePartsPageID;
            ModelPublicationID = modelPublicationID;
            ServicePartsPageID = servicePartsPageID;
        }
    }

    public partial class InnerPartLinkParams
    {
        public readonly Guid ModelID;
        public readonly string LanguageCode;

        public InnerPartLinkParams(Guid modelID, string languageCode)
        {
            ModelID = modelID;
            LanguageCode = languageCode;
        }
    }

    public partial class PartLinkInfo
    {
        public string PartNumber { get; set; }
    }
}